home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / economic / aertt.bst < prev    next >
Text File  |  1993-05-28  |  27KB  |  1,222 lines

  1. % BibTeX bibliography style `aertt'
  2. % this file is based on the `harvard' family of files
  3.         % version 0.99a for BibTeX versions 0.99a or later, LaTeX version 2.09.
  4.         % Copyright (C) 1991, all rights reserved.
  5.         % Copying of this file is authorized only if either
  6.         % (1) you make absolutely no changes to your copy, including name, or
  7.         % (2) if you do make changes, you name it something other than
  8.         % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, abbrv.bst, agsm.bst,
  9.         % dcu.bst, cje.bst, aer.bst, or kluwer.bst.
  10.         % This restriction helps ensure that all standard styles are identical.
  11.  
  12. % ACKNOWLEDGEMENT:
  13. %   This document is a modified version of alpha.bst to which it owes much of
  14. %   its functionality.
  15.  
  16. % AUTHOR
  17. %   Peter Williams, Key Centre for Design Quality, Sydney University
  18. %   e-mail: peterw@archsci.arch.su.oz.au
  19.  
  20. ENTRY
  21.   { address author booktitle chapter edition editor howpublished institution
  22.     journal key month note number organization pages publisher school
  23.     series title type volume year}
  24.   { field.used }
  25.   { label.touse extra.label sort.label list.year }
  26.  
  27.  
  28. FUNCTION {not}
  29. {   { #0 }
  30.     { #1 }
  31.   if$
  32. }
  33.  
  34. FUNCTION {and}
  35. {   {}
  36.     { pop$ #0 }
  37.   if$
  38. }
  39.  
  40. FUNCTION {or}
  41. {   { pop$ #1 }
  42.     {}
  43.   if$
  44. }
  45.  
  46. INTEGERS {quoted italic bold plain attribute
  47.         space comma tiedcomma semicolon colon period block empty separator
  48.         prev.separator next.separator next.attribute}
  49.  
  50. STRINGS { s temp f name.list first.name.format later.name.formats name.style}
  51.  
  52. FUNCTION {init.state.consts}
  53. {
  54.   #100  'quoted :=
  55.   #200  'italic :=
  56.   #300  'bold   :=
  57.   #400  'plain  :=
  58.  
  59.   #7 'space :=
  60.   #6 'comma :=
  61. %  #5 'tiedcomma :=
  62. %  #4 'semicolon :=
  63.   #3 'colon :=
  64.   #2 'period :=
  65.   #1 'block :=
  66.   #0 'empty :=
  67. }
  68.  
  69. FUNCTION {output2}
  70. {
  71. % Wrap the attribute.
  72.     attribute bold = {"{\bf " swap$ * "}" *} {} if$
  73.     attribute italic = {"\uline{" swap$ * "}" *} {} if$
  74.     attribute quoted = {"``" swap$ * "''" *} {} if$
  75. % Append additional separators
  76.     separator comma = {"," * space 'separator :=} {} if$
  77. %    separator tiedcomma = {",~" * empty 'separator :=} {} if$
  78.     separator space = {" " *} {} if$
  79.     write$
  80.     separator block = {newline$ "\newblock " write$} {} if$
  81. % Update variables, and put the new string back on the stack
  82.     next.attribute 'attribute :=
  83.     next.separator 'separator :=
  84.     temp
  85. }
  86.  
  87. % <string> <separator> <string> <attribute> <final separator> output <string>
  88. FUNCTION {output.nonnull}
  89. {   'next.separator :=
  90.     'next.attribute :=
  91.     'temp :=
  92.     'prev.separator :=
  93. % If the new separator is stronger than the previous one, use it.
  94.     prev.separator separator < {prev.separator 'separator :=} {} if$
  95. % Append most separators to the string.
  96.     separator block = {add.period$} {} if$
  97.     separator period = {add.period$ space 'separator :=} {} if$
  98. %    separator semicolon = {";" * space 'separator :=} {} if$
  99.     separator colon = {":" * space 'separator :=} {} if$
  100.     separator comma = attribute quoted = and
  101.         {"," * space 'separator :=} {} if$
  102.     output2
  103. }
  104.  
  105. FUNCTION {output}
  106. {   'next.separator :=
  107.     'next.attribute :=
  108.     duplicate$ empty$
  109.         {pop$ pop$}
  110.         {next.attribute next.separator output.nonnull}
  111.         if$
  112. }
  113.  
  114. FUNCTION {output.check}
  115. {   's :=
  116.     'next.separator :=
  117.     'next.attribute :=
  118.     duplicate$ empty$
  119.         {pop$ pop$ "empty " s * " in " * cite$ * warning$ }
  120.         {next.attribute next.separator output.nonnull}
  121.         if$
  122. }
  123.  
  124. FUNCTION {item.check}
  125. { 'temp :=
  126.   empty$
  127.     { "empty " temp * " in " * cite$ * warning$ }
  128.     {}
  129.   if$
  130. }
  131.  
  132. FUNCTION {plain.space} { plain space }
  133.  
  134. FUNCTION {plain.space.output} { plain.space output }
  135.  
  136. FUNCTION {plain.comma} { plain comma }
  137.  
  138. FUNCTION {fin.entry}
  139.   block note plain.space.output
  140.   period "" plain empty output.nonnull pop$
  141.   newline$
  142. }
  143.  
  144. FUNCTION {field.or.null}
  145. { duplicate$ empty$
  146.     { pop$ "" }
  147.     {}
  148.   if$
  149. }
  150.  
  151. FUNCTION {emphasize}
  152. { duplicate$ empty$
  153.     { pop$ "" }
  154.     { "{\em " swap$ * "}" * }
  155.   if$
  156. }
  157.  
  158. FUNCTION {quote}
  159. { duplicate$ empty$
  160.     { pop$ "" }
  161.     { add.period$ "`" swap$ * "'" * }
  162.   if$
  163. }
  164.  
  165.  
  166. % <prev name list> <new name list> compare.names <modified name list>
  167. INTEGERS {len1 len2 i}
  168. FUNCTION {compare.names}
  169. {   's :=
  170.     'temp :=
  171.     temp num.names$ 'len1 :=
  172.     s num.names$ 'len2 :=
  173. % len1 := min(len1,len2)
  174.     len1 len2 > {len2 'len1 :=} {} if$
  175. % start with an empty string, then while the components are the same
  176. % add "\bysame"
  177.     ""
  178.     #1 'i :=
  179.     {i len1 > not}
  180.     { temp i "{ff }{vv }{ll}{ jj}" format.name$
  181. % duplicate$ i int.to.str$ * warning$
  182.       s i "{ff }{vv }{ll}{ jj}" format.name$
  183. % duplicate$ i int.to.str$ * warning$
  184.       =
  185.         { #1 i < {" and " *} {} if$
  186.           "\bysame{}" * i #1 + 'i :=}
  187.         {#-1 'len1 :=}
  188.         if$
  189.       }
  190.     while$
  191. % add the rest of the second string
  192.     {i len2 > not}
  193.     { #1 i < {" and " *} {} if$
  194.       s i "{ff }{vv }{ll}{ jj}" format.name$ *
  195.       i #1 + 'i :=
  196.       }
  197.     while$
  198. % duplicate$ warning$
  199. }
  200.  
  201. INTEGERS { nameptr namesleft numnames }
  202.  
  203. FUNCTION {format.names}
  204. { 'name.list :=
  205.   'name.style :=
  206.   'later.name.formats :=
  207.   's := % binary separator
  208.   'first.name.format :=
  209.   #1 'nameptr :=
  210.   name.list num.names$ 'numnames :=
  211. % If we're to make this entry bold or something, prepend to the string of names
  212.   name.style "" = {} {"{" name.style *} if$
  213.   numnames 'namesleft :=
  214.     { namesleft #0 > }
  215.     { name.list nameptr nameptr #1 = {first.name.format} {later.name.formats} if$
  216.                 format.name$ 'temp :=
  217.       nameptr #1 >
  218.         { namesleft #1 >
  219.             { ", " * temp * }
  220.             { temp "others" =
  221.                 { " et~al." * }
  222.                 {nameptr #2 =   % handle ", and" vs " and "
  223.                     {s * temp *}
  224.                     {", and " * temp * }
  225.                     if$
  226.                 }
  227.                 if$
  228.             }
  229.             if$
  230.         }
  231.         'temp
  232.         if$
  233.       nameptr #1 + 'nameptr :=
  234.       namesleft #1 - 'namesleft :=
  235.     }
  236.   while$
  237. % If we're to make this entry bold or something, append to the string of names
  238.   name.style "" = {} {"}" * *}  if$
  239. }
  240.  
  241. FUNCTION {format.authors}
  242. { 'temp :=
  243.     "{vv~}{ll}{, jj}{, ff}" " and " "{ff~}{vv~}{ll}{, jj}" "" temp
  244.                 format.names
  245. }
  246.  
  247. FUNCTION {format.editors}
  248. { 'temp :=
  249.     "{vv~}{ll}{, jj}{, ff}" " and " "{ff~}{vv~}{ll}{, jj}" ""
  250.                 temp format.names
  251.       editor num.names$ #1 >
  252.         { ", eds" * }
  253.         { ", ed." * }
  254.       if$
  255. }
  256.  
  257. FUNCTION {format.editors.notkey}
  258. { editor empty$
  259.     { "" }
  260.     { "{ff~}{vv~}{ll}{, jj}" " and " "{ff~}{vv~}{ll}{, jj}" ""
  261.                 editor format.names
  262.       editor num.names$ #1 > {", eds."} {", ed."} if$
  263.       *
  264.     }
  265.   if$
  266. }
  267.  
  268. FUNCTION {format.title}
  269. { space title quoted comma }
  270.  
  271. FUNCTION {n.dashify}
  272. { 'temp :=
  273.   ""
  274.     { temp empty$ not }
  275.     { temp #1 #1 substring$ "-" =
  276.         { temp #1 #2 substring$ "--" = not
  277.             { "--" *
  278.               temp #2 global.max$ substring$ 'temp :=
  279.             }
  280.             {   { temp #1 #1 substring$ "-" = }
  281.                 { "-" *
  282.                   temp #2 global.max$ substring$ 'temp :=
  283.                 }
  284.               while$
  285.             }
  286.           if$
  287.         }
  288.         { temp #1 #1 substring$ *
  289.           temp #2 global.max$ substring$ 'temp :=
  290.         }
  291.       if$
  292.     }
  293.   while$
  294. }
  295.  
  296. FUNCTION {format.btitle}
  297. { title emphasize
  298. }
  299.  
  300. FUNCTION {tie.or.space.connect}
  301. { duplicate$ text.length$ #3 <
  302.     { "~" }
  303.     { " " }
  304.   if$
  305.   swap$ * *
  306. }
  307.  
  308. FUNCTION {either.or.check}
  309. { empty$
  310.     'pop$
  311.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  312.   if$
  313. }
  314.  
  315. FUNCTION {format.bvolume}
  316. { volume empty$
  317.     { "" }
  318.     { "Vol." volume tie.or.space.connect
  319.       series empty$
  320.         {}
  321.         { " of " * series emphasize * }
  322.       if$
  323.       "volume and number" number either.or.check
  324.     }
  325.   if$
  326. }
  327.  
  328. FUNCTION {format.bvolume.output}
  329.   {comma format.bvolume plain.space.output}
  330.  
  331. FUNCTION {mid.sentence.q}
  332. {
  333.     separator empty = separator block = separator period = or or not
  334. }
  335.  
  336. FUNCTION {format.number.series}
  337. { volume empty$
  338.     { number empty$
  339.         {series field.or.null}
  340.         { mid.sentence.q
  341.             { "number" }
  342.             { "Number" }
  343.           if$
  344.           number tie.or.space.connect
  345.           series empty$
  346.             { "there's a number but no series in " cite$ * warning$ }
  347.             { add.period$ " In " * series quote * }
  348.           if$
  349.         }
  350.       if$
  351.     }
  352.     { "" }
  353.   if$
  354. }
  355.  
  356. FUNCTION {format.edition.output}
  357. { edition empty$
  358.     { }
  359.     { comma edition
  360.       mid.sentence.q { "l" } { "t" } if$
  361.       change.case$ " ed." *
  362.       plain.space.output
  363.     }
  364.   if$
  365. }
  366.  
  367. FUNCTION {format.publisher.address}
  368. {
  369.     address empty$
  370.         {comma publisher plain.comma output}
  371.         {publisher empty$
  372.             {}
  373.             {comma address plain colon output
  374.              colon publisher plain.comma output}
  375.             if$}
  376.          if$
  377. }
  378.  
  379. INTEGERS { multiresult }
  380.  
  381. FUNCTION {multi.page.check}
  382. { 'temp :=
  383.   #0 'multiresult :=
  384.     { multiresult not
  385.       temp empty$ not
  386.       and
  387.     }
  388.     { temp #1 #1 substring$
  389.       duplicate$ "-" =
  390.       swap$ duplicate$ "," =
  391.       swap$ "+" =
  392.       or or
  393.         { #1 'multiresult := }
  394.         { temp #2 global.max$ substring$ 'temp := }
  395.       if$
  396.     }
  397.   while$
  398.   multiresult
  399. }
  400.  
  401. FUNCTION {format.pages}
  402. { pages empty$
  403.     { "" }
  404.     { pages multi.page.check
  405.         { "pp.~" pages n.dashify * }
  406.         { "p.~" pages * }
  407.       if$
  408.     }
  409.   if$
  410. }
  411.  
  412. FUNCTION {output.month.year}
  413.   {
  414.       space month plain.space.output
  415.       space year plain.comma "year" output.check
  416.   }
  417.  
  418. FUNCTION {output.vol.num.pages}
  419. { space volume italic space output
  420.   number empty$
  421.     {}
  422.     { space "(" number * ")" * plain.comma output.nonnull
  423.       volume empty$
  424.         { "there's a number but no volume in " cite$ * warning$ }
  425.         {}
  426.       if$
  427.     }
  428.   if$
  429. % "*** a" warning$
  430.   comma 'next.separator :=      % hack
  431.   pages empty$
  432.     {}
  433.     { number empty$ volume empty$ and
  434.         { comma format.pages plain.space.output }
  435.         { comma pages n.dashify plain.space.output }
  436.       if$
  437.     }
  438.   if$
  439. }
  440.  
  441. FUNCTION {format.chapter.pages}
  442. { chapter empty$
  443.     'format.pages
  444.     { type empty$
  445.         { "chapter" }
  446.         { type "l" change.case$ }
  447.       if$
  448.       chapter tie.or.space.connect
  449.       pages empty$
  450.         {}
  451.         { ", " * format.pages * }
  452.       if$
  453.     }
  454.   if$
  455. }
  456.  
  457. FUNCTION {output.in.ed.booktitle}
  458. { booktitle "booktitle" item.check
  459.   comma "in" plain.space output.nonnull
  460.   editor empty$
  461.     { space booktitle quoted space output.nonnull}
  462.     { space format.editors.notkey plain.space output.nonnull
  463.           comma booktitle italic comma output.nonnull
  464.      }
  465.      if$
  466. }
  467.  
  468. FUNCTION {empty.misc.check}
  469. { author empty$ title empty$ howpublished empty$
  470.   month empty$ year empty$ note empty$
  471.   and and and and and
  472.   key empty$ not and
  473.     { "all relevant fields are empty in " cite$ * warning$ }
  474.     {}
  475.   if$
  476. }
  477.  
  478. FUNCTION {format.thesis.type}
  479. { type empty$
  480.     {}
  481.     { pop$
  482.       type "t" change.case$
  483.     }
  484.   if$
  485. }
  486.  
  487. FUNCTION {format.tr.number}
  488. { type empty$
  489.     { "Technical Report" }
  490.     'type
  491.   if$
  492.   number empty$
  493.     {  }
  494.     { number tie.or.space.connect }
  495.   if$
  496. }
  497.  
  498. FUNCTION {format.article.crossref}
  499. { key empty$
  500.     { journal empty$
  501.         { "need key or journal for " cite$ * " to crossref " * crossref *
  502.           warning$
  503.           ""
  504.         }
  505.         { "in {\it " journal * "\/} \cite{" * crossref * "}" *}
  506.       if$
  507.     }
  508.     { add.period$ "In \citeasnoun{" crossref * "}" * }
  509.   if$
  510.  
  511. }
  512.  
  513. FUNCTION {format.book.crossref}
  514. { volume empty$
  515.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  516.       "in "
  517.     }
  518.     { "Vol." volume tie.or.space.connect
  519.       " of " *
  520.     }
  521.   if$
  522.   editor empty$
  523.   editor field.or.null author field.or.null =
  524.   or
  525.     { key empty$
  526.         { series empty$
  527.             { "need editor, key, or series for " cite$ * " to crossref " *
  528.               crossref * warning$
  529.               "" *
  530.             }
  531.             { "{\it " * series * "\/} \cite{" * crossref * "}" *}
  532.           if$
  533.         }
  534.         { " \citeasnoun{" * crossref * "}" * }
  535.       if$
  536.     }
  537.     { " \citeasnoun{" * crossref * "}" * }
  538.   if$
  539. }
  540.  
  541. FUNCTION {output.incoll.inproc.crossref}
  542. { editor empty$
  543.   editor field.or.null author field.or.null =
  544.   or
  545.     { key empty$
  546.         { booktitle empty$
  547.             { "need editor, key, or booktitle for " cite$ * " to crossref " *
  548.               crossref * warning$
  549.             }
  550.             { period "In {\it " booktitle * "\/}" * " \cite{" * crossref * "}" * plain.space output.nonnull}
  551.           if$
  552.         }
  553.         { period "In \citeasnoun{" crossref * "}" * plain.space output.nonnull}
  554.       if$
  555.     }
  556.     { period "In \citeasnoun{" crossref * "}" * plain.space output.nonnull}
  557.   if$
  558. }
  559.  
  560. INTEGERS { len }
  561.  
  562. FUNCTION {chop.word}
  563. { 's :=
  564.   'len :=
  565.   s #1 len substring$ =
  566.     { s len #1 + global.max$ substring$ }
  567.     's
  568.   if$
  569. }
  570.  
  571. INTEGERS { author.field editor.field organization.field title.field key.field }
  572.  
  573. FUNCTION {init.field.constants}
  574. { #0 'author.field :=
  575.   #1 'editor.field :=
  576.   #2 'organization.field :=
  577.   #3 'title.field :=
  578.   #4 'key.field :=
  579. }
  580.  
  581. FUNCTION {format.lab.names.abbr}
  582. { 'name.list :=
  583.   name.list num.names$ 'numnames :=
  584.   numnames #1 >
  585.     { numnames #2 >
  586.         { name.list #1 "{vv~}{ll}" format.name$ " et al." * }
  587.         { name.list #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  588.             { name.list #1 "{vv~}{ll}" format.name$ " et al." * }
  589.             { name.list #1 "{vv~}{ll}" format.name$ " and " *
  590.               name.list #2 "{vv~}{ll}" format.name$ * 
  591.             }
  592.           if$
  593.         }
  594.       if$
  595.       field.used editor.field = {", eds" *} {} if$
  596.     }
  597.     {
  598.         name.list #1 "{vv~}{ll}" format.name$
  599.         field.used editor.field = {", ed" *} {} if$
  600.     }
  601.   if$
  602. }
  603.  
  604. FUNCTION {format.lab.names.full}
  605. { 'name.list :=
  606.   #1 'nameptr :=
  607.   name.list num.names$ 'numnames :=
  608.   numnames 'namesleft :=
  609.     { namesleft #0 > }
  610.     { name.list nameptr "{vv~}{ll}" format.name$ 'temp :=
  611.       nameptr #1 >
  612.         { namesleft #1 >
  613.             { ", " * temp * }
  614.             { temp "others" =
  615.                 { " et~al." * }
  616.                 { " and " * temp * }
  617.               if$
  618.             }
  619.           if$
  620.         }
  621.         'temp
  622.       if$
  623.       nameptr #1 + 'nameptr :=
  624.       namesleft #1 - 'namesleft :=
  625.     }
  626.   while$
  627.   numnames #1 > field.used editor.field = and {", eds" *} {} if$
  628.   numnames #1 = field.used editor.field = and {", ed" *} {} if$
  629. }
  630.  
  631. STRINGS { prev.author }
  632.  
  633. FUNCTION {make.list.label}
  634. {author.field field.used =
  635.     { prev.author author compare.names format.authors
  636.          author 'prev.author :=}
  637.     { editor.field field.used =
  638.         { prev.author editor compare.names format.editors
  639.                 editor 'prev.author := }
  640.         { organization.field field.used =
  641.             { "The " #4 organization chop.word
  642.                 duplicate$ prev.author = {pop$ "\bysame{}"}
  643.                                          {duplicate$ 'prev.author :=} if$}
  644.             { "foo" 'prev.author :=
  645.               title.field field.used =
  646.                 { format.btitle }
  647.                 { key.field field.used =
  648.                     { key #3 text.prefix$ }
  649.                     { "Internal error :001 on " cite$ * " label" * warning$ }
  650.                   if$
  651.                 }
  652.               if$
  653.             }
  654.           if$
  655.         }
  656.       if$
  657.     }
  658.   if$
  659. }
  660.  
  661. FUNCTION {make.full.label}
  662. { author.field field.used =
  663.     { author format.lab.names.full }
  664.     { editor.field field.used =
  665.         { editor format.lab.names.full }
  666.         { organization.field field.used =
  667.             { "The " #4 organization chop.word #3 text.prefix$ }
  668.             { title.field field.used =
  669.                 { format.btitle }
  670.                 { key.field field.used =
  671.                     { key #3 text.prefix$ }
  672.                     { "Internal error :001 on " cite$ * " label" * warning$ }
  673.                   if$
  674.                 }
  675.               if$
  676.             }
  677.           if$
  678.         }
  679.       if$
  680.     }
  681.   if$
  682. }
  683.  
  684. FUNCTION {make.abbr.label}
  685. { author.field field.used =
  686.     { author format.lab.names.abbr }
  687.     { editor.field field.used =
  688.         { editor format.lab.names.abbr }
  689.         { organization.field field.used =
  690.             { "The " #4 organization chop.word #3 text.prefix$ }
  691.             { title.field field.used =
  692.                 { format.btitle }
  693.                 { key.field field.used =
  694.                     { key #3 text.prefix$ }
  695.                     { "Internal error :001 on " cite$ * " label" * warning$ }
  696.                   if$
  697.                 }
  698.               if$
  699.             }
  700.           if$
  701.         }
  702.       if$
  703.     }
  704.   if$
  705. }
  706.  
  707. FUNCTION {output.bibitem}
  708. { newline$
  709.   "\harvarditem[" write$
  710.   make.abbr.label write$
  711.   "]{" write$
  712.   make.full.label write$
  713.   "}{" write$
  714.   list.year write$
  715.   "}{" write$
  716.   cite$ write$
  717.   "}" write$
  718.   newline$
  719.   ""
  720.   empty 'separator :=
  721.   plain 'attribute :=
  722. % }
  723. %
  724. %  FUNCTION {list.label.output}
  725. % {
  726.   space make.list.label plain comma output.nonnull
  727.   }
  728.  
  729. FUNCTION {author.item.check} {author "author" item.check}
  730.  
  731. FUNCTION {format.title.if.not.sortkey.check}
  732. {title.field field.used =
  733.     {}
  734.     { format.title "title" output.check }
  735.   if$}
  736.  
  737. FUNCTION {article}
  738. { output.bibitem
  739.   author.item.check
  740.   format.title.if.not.sortkey.check
  741.   crossref missing$
  742.     { space journal italic comma "journal" output.check
  743.       output.month.year
  744.       output.vol.num.pages
  745.     }
  746.     { space format.article.crossref plain.space output.nonnull
  747.       comma format.pages plain.space.output
  748.     }
  749.   if$
  750.   fin.entry
  751. }
  752.  
  753. FUNCTION {book}
  754. { output.bibitem
  755.     author empty$
  756.     { editor "author and editor" item.check }
  757.     { crossref missing$
  758.         { "author and editor" editor either.or.check }
  759.         {}
  760.       if$
  761.     }
  762.   if$
  763.   title.field field.used =
  764.     {}
  765.     { space title italic space "title" output.check }
  766.   if$
  767.   crossref missing$
  768.     { 
  769.       space format.number.series plain.space.output
  770.       format.edition.output
  771.       format.bvolume.output
  772.       format.publisher.address
  773.       output.month.year
  774.     }
  775.     { space format.book.crossref plain.space output.nonnull
  776.       format.edition.output
  777.     }
  778.   if$
  779.   fin.entry
  780. }
  781.  
  782. FUNCTION {booklet}
  783. { output.bibitem
  784.   format.title.if.not.sortkey.check
  785.   space howpublished plain.space.output
  786.   space address plain.space.output
  787.   output.month.year
  788.   fin.entry
  789. }
  790.  
  791. FUNCTION {inbook}
  792. { output.bibitem
  793.     author empty$
  794.     { editor "author and editor" item.check }
  795.     { crossref missing$
  796.         { "author and editor" editor either.or.check }
  797.         {}
  798.       if$
  799.     }
  800.   if$
  801.   title.field field.used =
  802.     {}
  803.     { space title italic space "title" output.check }
  804.   if$
  805.   crossref missing$
  806.     { space format.number.series plain.space.output
  807.       format.edition.output
  808.       comma format.bvolume plain.comma output
  809.       format.publisher.address
  810.       output.month.year
  811.     }
  812.     { space format.book.crossref plain.space output.nonnull
  813.       format.edition.output
  814.     }
  815.   if$
  816.   format.chapter.pages "chapter and pages" output.check
  817.   fin.entry
  818. }
  819.  
  820. FUNCTION {incollection}
  821. { output.bibitem
  822.   format.title.if.not.sortkey.check
  823.   author.item.check
  824.   crossref missing$
  825.     { output.in.ed.booktitle
  826.       format.edition.output
  827.       format.bvolume.output
  828.       space format.number.series plain.space.output
  829.       format.publisher.address
  830.       output.month.year
  831.     }
  832.     { output.incoll.inproc.crossref }
  833.   if$
  834.   space format.chapter.pages plain.space.output
  835.   fin.entry
  836. }
  837.  
  838. FUNCTION {inproceedings}
  839. { output.bibitem
  840.   format.title.if.not.sortkey.check
  841.   author.item.check
  842.   crossref missing$
  843.     { output.in.ed.booktitle
  844.       format.bvolume.output
  845.       space format.number.series plain.space.output
  846.       address empty$
  847.         { space organization plain.space.output
  848.           space publisher plain.space.output
  849.         }
  850.         { space organization plain.space.output
  851.           space publisher plain.space.output
  852.           space address plain.space output.nonnull
  853.         }
  854.       if$
  855.       output.month.year
  856.     }
  857.     { output.incoll.inproc.crossref}
  858.   if$
  859.   space format.pages plain.space.output
  860.   fin.entry
  861. }
  862.  
  863. FUNCTION {conference} { inproceedings }
  864.  
  865. FUNCTION {manual}
  866. { output.bibitem
  867.     title.field field.used =
  868.     {}
  869.     {author empty$ {comma}{space} if$ title italic space "title" output.check }
  870.   if$
  871.   organization.field field.used = organization empty$ or
  872.         {} {space organization plain.space output.nonnull} if$
  873.   format.edition.output
  874.   format.publisher.address
  875.   output.month.year
  876.   fin.entry
  877. }
  878.  
  879. FUNCTION {mastersthesis}
  880. { output.bibitem
  881.   author.item.check
  882.   format.title.if.not.sortkey.check
  883.   space "Master's thesis" format.thesis.type plain.space output.nonnull
  884.   comma school plain.space "school" output.check
  885.   comma address plain.space.output
  886.   output.month.year
  887.   fin.entry
  888. }
  889.  
  890. FUNCTION {misc}
  891. { output.bibitem
  892.   format.title.if.not.sortkey.check
  893.   space howpublished plain.space.output
  894.   output.month.year
  895.   fin.entry
  896.   empty.misc.check
  897. }
  898.  
  899. FUNCTION {phdthesis}
  900. { output.bibitem
  901.     author.item.check
  902.   title.field field.used =
  903.     {}
  904.     { space title quoted period "title" output.check }
  905.   if$
  906.   space "PhD dissertation" format.thesis.type plain.space output.nonnull
  907.   comma school plain.space "school" output.check
  908.   comma address plain.space.output
  909.   output.month.year
  910.   fin.entry
  911. }
  912.  
  913. FUNCTION {proceedings}
  914. { output.bibitem
  915.     title.field field.used =
  916.     {}
  917.     { space title italic space "title" output.check }
  918.   if$
  919.   format.bvolume.output
  920.   space format.number.series plain.space.output
  921.   address empty$
  922.     { editor empty$
  923.         {}
  924.         { space organization plain.space.output
  925.         }
  926.       if$
  927.       space publisher plain.space.output
  928.     }
  929.     { editor empty$
  930.         {}
  931.         { space organization plain.space.output }
  932.       if$
  933.       space publisher plain.space.output
  934.       space address plain.space output.nonnull
  935.     }
  936.   if$
  937.   output.month.year
  938.   fin.entry
  939. }
  940.  
  941. FUNCTION {techreport}
  942. { output.bibitem
  943.   author.item.check
  944.   format.title.if.not.sortkey.check
  945.   space format.tr.number plain.space output.nonnull
  946.   institution empty$
  947.     {}
  948.     { comma institution plain.space "institution" output.check }
  949.     if$
  950.   comma address plain.space.output
  951.   output.month.year
  952.   fin.entry
  953. }
  954.  
  955. FUNCTION {unpublished}
  956. { output.bibitem
  957.     author.item.check
  958.   format.title.if.not.sortkey.check
  959.   output.month.year
  960.   note "note" item.check
  961.   fin.entry
  962. }
  963.  
  964. FUNCTION {default.type} { misc }
  965.  
  966. MACRO {jan} {"January"}
  967.  
  968. MACRO {feb} {"February"}
  969.  
  970. MACRO {mar} {"March"}
  971.  
  972. MACRO {apr} {"April"}
  973.  
  974. MACRO {may} {"May"}
  975.  
  976. MACRO {jun} {"June"}
  977.  
  978. MACRO {jul} {"July"}
  979.  
  980. MACRO {aug} {"August"}
  981.  
  982. MACRO {sep} {"September"}
  983.  
  984. MACRO {oct} {"October"}
  985.  
  986. MACRO {nov} {"November"}
  987.  
  988. MACRO {dec} {"December"}
  989.  
  990. READ
  991.  
  992. EXECUTE {init.field.constants}
  993.  
  994. FUNCTION {sortify}
  995. { purify$
  996.   "l" change.case$
  997. }
  998.  
  999. FUNCTION {author.editor.key.label}
  1000. { author empty$
  1001.     { editor empty$
  1002.         { title empty$
  1003.             { key.field 'field.used := }
  1004.             { title.field 'field.used := }
  1005.           if$
  1006.         }
  1007.         { editor.field 'field.used := }
  1008.       if$
  1009.     }
  1010.     { author.field 'field.used := }
  1011.   if$
  1012. }
  1013.  
  1014. FUNCTION {key.organization.label}
  1015.  {organization empty$
  1016.         { title empty$
  1017.             { key.field 'field.used := }
  1018.             { title.field 'field.used := }
  1019.           if$
  1020.         }
  1021.         { organization.field 'field.used := }
  1022.         if$}
  1023.  
  1024. FUNCTION {author.key.organization.label}
  1025. { author empty$
  1026.     { key.organization.label}
  1027.     { author.field 'field.used := }
  1028.     if$
  1029. }
  1030.  
  1031. FUNCTION {editor.key.organization.label}
  1032. { editor empty$
  1033.     { key.organization.label}
  1034.     { editor.field 'field.used := }
  1035.   if$
  1036. }
  1037.  
  1038. FUNCTION {sort.format.title}
  1039. { 'temp :=
  1040.   "A " #2
  1041.     "An " #3
  1042.       "The " #4 temp chop.word
  1043.     chop.word
  1044.   chop.word
  1045.   sortify
  1046.   #1 global.max$ substring$
  1047. }
  1048.  
  1049. FUNCTION {calc.label}
  1050. { type$ "book" =
  1051.   type$ "inbook" =
  1052.   or
  1053.     'author.editor.key.label
  1054.     { type$ "proceedings" =
  1055.         'editor.key.organization.label
  1056.         { type$ "manual" =
  1057.             'author.key.organization.label
  1058.             'author.editor.key.label    % don't really use .editor.
  1059.           if$
  1060.         }
  1061.       if$
  1062.     }
  1063.   if$
  1064.   make.abbr.label
  1065.   title.field field.used =
  1066.     { sort.format.title }
  1067.     { sortify }
  1068.   if$
  1069.   year field.or.null purify$ #-1 #4 substring$ sortify
  1070.   *
  1071.   'sort.label :=
  1072. }
  1073.  
  1074. FUNCTION {first.presort}
  1075. { "abcxyz" 'prev.author :=
  1076.   calc.label
  1077.   sort.label
  1078.   title.field field.used =
  1079.     {}
  1080.     { "    "
  1081.       *
  1082.       make.list.label sortify
  1083.       *
  1084.       "    "
  1085.       *
  1086.       title field.or.null
  1087.       sort.format.title
  1088.       *
  1089.     }
  1090.   if$
  1091.   #1 entry.max$ substring$
  1092.   'sort.key$ :=
  1093. }
  1094.  
  1095.  
  1096. ITERATE {first.presort}
  1097.  
  1098. SORT
  1099.  
  1100. STRINGS { last.sort.label next.extra }
  1101.  
  1102. INTEGERS { last.extra.num }
  1103.  
  1104. FUNCTION {initialize.last.extra.num}
  1105. { #0 int.to.chr$ 'last.sort.label :=
  1106.   "" 'next.extra :=
  1107.   #0 'last.extra.num :=
  1108. }
  1109.  
  1110. FUNCTION {forward.pass}
  1111. { last.sort.label sort.label =
  1112.     { last.extra.num #1 + 'last.extra.num :=
  1113.       last.extra.num int.to.chr$ 'extra.label :=
  1114.     }
  1115.     { "a" chr.to.int$ 'last.extra.num :=
  1116.       "" 'extra.label :=
  1117.       sort.label 'last.sort.label :=
  1118.     }
  1119.   if$
  1120. }
  1121.  
  1122. FUNCTION {reverse.pass}
  1123. { next.extra "b" =
  1124.     { "a" 'extra.label := }
  1125.     {}
  1126.   if$
  1127.   year empty$
  1128.     { "n.d." extra.label * 'list.year := }
  1129.     { year extra.label * 'list.year := }
  1130.   if$
  1131.   extra.label 'next.extra :=
  1132. }
  1133.  
  1134. EXECUTE {initialize.last.extra.num}
  1135.  
  1136. ITERATE {forward.pass}
  1137.  
  1138. REVERSE {reverse.pass}
  1139.  
  1140. FUNCTION {second.presort}
  1141. { "abcxyz" 'prev.author :=
  1142.   make.list.label
  1143.   title.field field.used =
  1144.     { sort.format.title }
  1145.     { sortify }
  1146.   if$
  1147.   "    "
  1148.   *
  1149.   list.year field.or.null sortify
  1150.   *
  1151.   "    "
  1152.   *
  1153.   title.field field.used =
  1154.     {}
  1155.     { title field.or.null
  1156.       sort.format.title
  1157.       *
  1158.     }
  1159.   if$
  1160.   #1 entry.max$ substring$
  1161.   'sort.key$ :=
  1162. }
  1163.  
  1164. ITERATE {second.presort}
  1165.  
  1166. SORT
  1167.  
  1168.  
  1169. INTEGERS { number.label }
  1170.  
  1171. FUNCTION {initialize.longest.label}
  1172. {
  1173.   #1 'number.label :=
  1174.   "abcxyz" 'prev.author :=
  1175. }
  1176.  
  1177. FUNCTION {longest.label.pass}
  1178.     "" 'extra.label :=
  1179.     author empty$ { editor empty$ {"foo"} {editor} if$}
  1180.                   {author}
  1181.                    if$
  1182.     'f :=
  1183. % remember this entry to compare to the next one
  1184.     author empty$ { editor empty$ {"abcxyz"} {editor} if$} {author} if$
  1185.         'prev.author := 
  1186. }
  1187.  
  1188. EXECUTE {initialize.longest.label}
  1189.  
  1190. ITERATE {longest.label.pass}
  1191.  
  1192. FUNCTION {begin.bib}
  1193. { preamble$ empty$
  1194.     {}
  1195.     { preamble$ write$ newline$ }
  1196.   if$
  1197.   "\ifx\undefined\bysame" write$ newline$
  1198.   "\newcommand{\bysame}{\leavevmode\hbox to\leftmargin{\hrulefill\,\,}}"
  1199.        write$ newline$
  1200.   "\fi" write$ newline$
  1201.   "\begin{thebibliography}{xx}" write$ newline$
  1202. }
  1203.  
  1204. EXECUTE {begin.bib}
  1205.  
  1206. EXECUTE {init.state.consts}
  1207.  
  1208. FUNCTION {init.call}
  1209.  { "abcxyz" 'prev.author := }
  1210.  
  1211. EXECUTE {init.call}
  1212.  
  1213. ITERATE {call.type$}
  1214.  
  1215. FUNCTION {end.bib}
  1216.         {newline$ "\end{thebibliography}" write$ newline$ }
  1217.  
  1218. EXECUTE {end.bib}
  1219.  
  1220.